import md5 from 'md5';
// import { isLogin } from 'components/common/api';
import { _isLogin } from '../../api/index';
const loginFunc=(result,values) =>({
    type:'LOGIN',
    result,
    values,
})

export const logout=() =>({
    type:'LOGOUT'
});

export  const login =(values) =>{
    const salt = 'fndjvrfewewq9eu!';
    return (dispatch) =>{
        for( var key in values){
            if(key =='password'){
                values[key] = md5(md5(values[key]+salt))
            }
        }
        async function handleRequest(){
           let res = await _isLogin(values)
           console.log("res=====",res)
           console.log("res.status=====",res.status)
           if(res.status ===200 || res.status==='200'){
                dispatch(loginFunc(res,values))
            }else{
                return
            }
        }
        handleRequest()
    }
}

